Type.registerNamespace("Telerik.Web.UI");
(function(){var b=$telerik.$;
var a=Telerik.Web.UI;
Telerik.Web.UI.RadFileExplorer=function(c){Telerik.Web.UI.RadFileExplorer.initializeBase(this,[c]);
this._localization={};
this._initialGridData={};
this._uniqueId="";
this._selectedFile=null;
this._pathSeparator="/";
this._gridPageSize=10;
this._enableCopy=false;
this._explorerMode=Telerik.Web.UI.FileExplorerMode.Default;
this._selectedRow=null;
this._folderCache=[];
this._gridData=null;
this._gridContextHandler=null;
this._actionsManager=null;
this._currentDirectoryInputID="";
this._postbackArgumentInputID="";
this._commandArgumentInputID="";
this._copiedPaths=[];
this._copyCursorClassName="rfeCopyCursor";
this._bindingGridFlag=false;
};
Telerik.Web.UI.RadFileExplorer.prototype={initialize:function(){Telerik.Web.UI.RadFileExplorer.callBaseMethod(this,"initialize");
this.raiseEvent("init",Sys.EventArgs.Empty);
this._attachAjaxPanelHandlers();
var g=this.get_tree();
if(g!=null){this._attachTreeHandlers();
}var d=this.get_grid();
if(d){this._attachGridHandlers();
var h=d.get_masterTableView();
if(this.get_allowPaging()&&this._gridPageSize!=h.get_pageSize()){h.set_pageSize(this._gridPageSize);
}this._bindGrid(this._initialGridData);
}var c=this.get_toolbar();
if(c!=null){c.add_buttonClicked(Function.createDelegate(this,this.toolbarClicked));
var f={redoAction:Function.createDelegate(this,this._executeBackForward),undoAction:Function.createDelegate(this,this._executeBackForward)};
this._actionsManager=$create(Telerik.Web.UI.ActionsManager,null,f);
this._updateToolbar();
}if($telerik.isFirefox){this._addFirefoxFormAutoComplete();
}if(!$telerik.isIE&&!$telerik.isOpera){this._copyCursorClassName+="CSS3";
}var e=$get(this._currentDirectoryInputID);
if(e){e.setAttribute("autocomplete","off");
}this._fixWindowLocalization();
this.set_commandArgument("");
this.raiseEvent("load",Sys.EventArgs.Empty);
},dispose:function(){this._gridData=null;
this._folderCache=null;
var c=this.get_gridPane().getContentElement();
if(c&&c._events){$removeHandler(c,"contextmenu",this._gridContextHandler);
}this._gridContextHandler=null;
Telerik.Web.UI.RadFileExplorer.callBaseMethod(this,"dispose");
},clearFolderCache:function(){this._folderCache=[];
},_fixWindowLocalization:function(){if(Telerik.Web.UI.RadWindowUtils&&Telerik.Web.UI.RadWindowUtils.Localization){var c=this.get_localization();
Telerik.Web.UI.RadWindowUtils.Localization.OK=c.OK;
Telerik.Web.UI.RadWindowUtils.Localization.Cancel=c.Cancel;
}},_addFirefoxFormAutoComplete:function(){var c=this.get_element();
while(c!=null&&c.tagName.toLowerCase()!="form"){c=c.parentNode;
}if(c!=null){c.setAttribute("autocomplete","off");
}},_postbackTreeAjaxPanel:function(c){var d=$get(this._postbackArgumentInputID);
d.value=c;
var e=$get(this.get_postbackButton());
e.click();
},_onAjaxRequestStart:function(c,d){var e=d.get_postBackElement();
if(e&&(e.id==this.get_postbackButton()||e.id==this.get_tree().get_id())){this._showLoadingPanel(this.get_treePane().get_id());
this.raiseEvent("ajaxRequestStart",Sys.EventArgs.Empty);
var f=this.get_tree();
this._treeId=f!=null?f.get_id():null;
d.get_request().isRFE=this.get_id();
}},_onAjaxResponseEnd:function(c,d){if(d.get_response()&&d.get_response().get_webRequest()&&d.get_response().get_webRequest().isRFE&&d.get_response().get_webRequest().isRFE==this.get_id()){this._hideLoadingPanel(this.get_treePane().get_id());
d.get_response().get_webRequest().isRFE=null;
if(this._treeId!=null){this.set_tree($find(this._treeId));
this._attachTreeHandlers();
}var e=this.get_currentDirectory();
this._makeGridCallback(e,true);
this.raiseEvent("ajaxRequestEnd",Sys.EventArgs.Empty);
}},_attachAjaxPanelHandlers:function(){Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Function.createDelegate(this,this._onAjaxRequestStart));
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(Function.createDelegate(this,this._onAjaxResponseEnd));
},_storeSelectedFiles:function(e){if(this.get_currentDirectory()==e){this._gridSelectedFiles=[];
var g=this.get_grid().get_masterTableView().get_selectedItems();
for(var f=0,c=g.length;
f<c;
f++){var d=g[f].get_dataItem()["Name"];
Array.add(this._gridSelectedFiles,d);
}}else{this._gridSelectedFiles=null;
}},_restoreSelectedFiles:function(){var e=this.get_grid().get_masterTableView();
if(this._gridSelectedFiles&&this._gridSelectedFiles.length>0){var m=e.get_dataItems();
for(var c=0,n=this._gridSelectedFiles.length;
c<n;
c++){var k=this._gridSelectedFiles[c];
for(var d=0,h=m.length;
d<h;
d++){var f=m[d];
if(f){var l=f.get_dataItem();
if(l&&l.Name==k){var g=f.get_element();
e.selectItem(g,true);
break;
}}}}}},_changeCurrentFolder:function(c){this.set_currentDirectory(c);
if(this._actionsManager!=null&&this._firstTimeLoading==null){this._firstTimeLoading=false;
this._setToolbarButtonEnabledState("Back",false);
}},_makeGridCallback:function(j,f,g,l,c){var i=this.get_grid();
if(!j||(!f&&this.get_currentDirectory()==j)){return;
}if(!i){this._changeCurrentFolder(j);
return;
}this._storeSelectedFiles(j);
i.clearActiveRow();
if(this._gridSortExpression==null){this._gridSortExpression="";
}if(g==null){g=this._gridSortExpression;
}else{this._gridSortExpression=g;
}var e=j+"***"+this._gridSortExpression;
if(this._folderCache[e]!=null&&!f){this._onCallbackResponse(this._folderCache[e],j);
}else{this._showLoadingPanel(this.get_gridPane().get_id());
if(null==l){l=0;
}if(null==c){c=i.get_masterTableView().get_pageSize();
}var d=String.format('{{ path : "{0}", sortExpression : "{1}", startIndex : {2}, maxRowNumber : {3}}}',j.replace(/\\/gi,"\\\\"),g.replace(/\\/gi,"\\\\"),l,c);
var h=Function.createDelegate(this,this._onCallbackResponse);
var k=Function.createDelegate(this,this._onCallbackError);
WebForm_DoCallback(this._uniqueId,d,h,j,k,true);
}},_onCallbackResponse:function(e,f){var d=this.get_grid();
d.clearSelectedItems();
this._changeCurrentFolder(f);
var i=d.get_masterTableView();
var h=Sys.Serialization.JavaScriptSerializer.deserialize(e);
this._bindGrid(h);
if(d.get_masterTableView().get_currentPageIndex()==0){var c=f+"***"+this._gridSortExpression;
this._folderCache[c]=e;
}d.repaint();
this._hideLoadingPanel(this.get_gridPane().get_id());
var g=this._getCurrentFolderItem();
this.raiseEvent("folderLoaded",new Telerik.Web.UI.RadFileExplorerEventArgs(g,""));
},_onCallbackError:function(d,c){alert("Callback Loading error:\n"+c+"\n"+d);
this._hideLoadingPanel(this.get_gridPane().get_id());
},_bindGrid:function(d){if(d&&d.data&&d.count!=null){this._bindingGridFlag=true;
this._gridData=[];
var c=this.get_grid().get_masterTableView();
c.set_dataSource(d.data);
c.dataBind();
c.set_virtualItemCount(d.count);
if(this._selectedRow){this._selectGridItem(this._selectedRow);
this._selectedRow=null;
}else{this._restoreSelectedFiles();
}this._bindingGridFlag=false;
}},loadFolder:function(e,d){if(!e){return;
}if(d==null){d=true;
}if(this.get_currentDirectory()==e&&d){return;
}var f=this._createItemFromPath(e);
var c=new Telerik.Web.UI.RadFileExplorerEventArgs(f,"");
this.raiseEvent("folderChange",c);
if(c.get_cancel()){return;
}this.set_currentDirectory(e,d);
this._postbackTreeAjaxPanel("LoadFolder_"+e);
},toolbarClicked:function(c,d){var e=d.get_item().get_value();
switch(e){case"Back":this._back();
break;
case"Forward":this._forward();
break;
case"Refresh":this.refresh();
break;
case"NewFolder":this.createNewDirectory();
break;
case"Delete":this.deleteSelectedItems();
break;
case"Upload":this._showUploadWindow();
break;
case"Open":this.open();
break;
}},_addItemToCopiedPaths:function(c){var d=c.isDirectory()?"D":"F";
d+=c.get_path();
Array.add(this._copiedPaths,d);
},_copy:function(f,g){this._copiedPaths=[];
if(g){this._addItemToCopiedPaths(g);
}else{if(f=="grid"){var m=this.get_grid();
if(m){var l=this.get_selectedItems();
for(var c=0;
c<l.length;
c++){this._addItemToCopiedPaths(l[c]);
}}}else{if(f=="tree"){var k=this.get_tree();
if(k){var h=k.get_selectedNodes();
for(var d=0;
d<h.length;
d++){var e=this._createItemFromTreeViewNode(h[d]);
this._addItemToCopiedPaths(e);
}}}}}},_paste:function(g){if(this._copiedPaths.length==0||!g.isDirectory()){return;
}var f=this._copiedPaths[0].substring(1);
var c=this._createItemFromPath(f);
var d=new Telerik.Web.UI.RadFileExplorerEventArgs(c,g.get_path());
this.raiseEvent("copy",d);
if(!d.get_cancel()){var e=g.get_path()+"***"+this._copiedPaths.join("***");
this._postbackTreeAjaxPanel("CallbackFnCopy_"+e);
}},_gridOpenFolder:function(d){var e=this.get_tree();
if(e!=null){var c=e.findNodeByValue(d);
if(c){c.select();
c.expand();
this._makeGridCallback(d);
}}},_isOpenExtension:function(c){return(c=="docx"||c=="doc"||c=="xlsx"||c=="xls"||c=="zip");
},open:function(c){if(!c){c=this.get_selectedItem();
}if(c){var f=new Telerik.Web.UI.RadFileExplorerEventArgs(c,"");
this.raiseEvent("fileOpen",f);
if(f.get_cancel()){return false;
}if(c.isDirectory()){this._gridOpenFolder(c.get_path());
}else{if(this.get_enableOpenFile()){var d=c.get_url();
if(this._isOpenExtension(c.get_extension())){window.location.href=d;
}else{var e=this.get_windowManager();
window.setTimeout(function(){var g=e.open(d,null);
g.set_title(c.get_name());
g.set_modal(false);
},10);
}}}}},deleteSelectedItems:function(){var c=this.get_selectedItems();
if(c&&c.length>0){this.deleteItem(c,c.length);
}},deleteItem:function(f,c){function d(g){if(g){this._deleteItem(f,c);
}}var e=this.get_windowManager();
e.radconfirm(this.get_localization()["ConfirmDelete"],Function.createDelegate(this,d),330,100,null,"Delete");
},_deleteItem:function(g,d){if(!Array.isInstanceOfType(g)){g=[g];
}var f="";
for(var h=0,c=g.length;
h<c;
h++){var j=g[h];
if(!j.get_path){j=this._createItemFromPath(j);
}if(j&&j.get_path){var e=new Telerik.Web.UI.RadFileExplorerEventArgs(j,"");
this.raiseEvent("delete",e);
if(e.get_cancel()){continue;
}f+=j.get_path()+"***";
}}if(f.length>0){this._postbackTreeAjaxPanel("CallbackFnDelete_"+f);
}},_createFolder:function(e,c){var f=this._createItemFromPath(e);
var d=new Telerik.Web.UI.RadFileExplorerEventArgs(f,c);
this.raiseEvent("createNewFolder",d);
if(d.get_cancel()){return false;
}var g=e+"***"+c;
this._postbackTreeAjaxPanel("CallbackFnCreate_"+g);
},createNewDirectory:function(g,c){if(!g){g=this.get_currentDirectory();
}if(!c){var f=this.get_localization()["CreateNewFolder"];
function e(i){if(i){this._createFolder(g,i);
}}var d=this;
var h=this.get_windowManager();
window.setTimeout(function(){h.radprompt(f,Function.createDelegate(d,e),330,100,null,f,"NewFolder");
},10);
}else{this._createFolder(g,c);
}},refresh:function(c){if(c&&!this._selectedFile){this._selectedFile=c;
}this.loadFolder(this.get_currentDirectory(),false);
},_showUploadWindow:function(){var c=this._getChildElement("uploadContainer");
var d=this.get_windowManager();
window.setTimeout(function(){c.style.overflow="";
c.style.height="auto";
c.style.width="auto";
var e=d.open(null,d.get_id()+"fileExplorerUpload");
e.set_contentElement(c);
},10);
},_updateToolbar:function(c,d){if(this.get_toolbar()==null){return;
}var f=Telerik.Web.UI.FileExplorerItemPermissions;
var e=this.get_currentPermissions();
this._setToolbarButtonEnabledState("Back",this._actionsManager&&this._actionsManager.canUndo());
this._setToolbarButtonEnabledState("Forward",this._actionsManager&&this._actionsManager.canRedo());
this._setToolbarButtonEnabledState("Open",true);
this._setToolbarButtonEnabledState("Refresh",true);
this._setToolbarButtonEnabledState("NewFolder",(e&f.Upload)!=0);
this._setToolbarButtonEnabledState("Upload",(e&f.Upload)!=0);
this._setToolbarButtonEnabledState("Delete",(e&f.Delete)!=0);
},_setToolbarButtonEnabledState:function(d,c){var e=this.get_toolbar();
if(e!=null){e.get_items().forEach(function(f){if(f.get_value()==d||d=="all"){f.set_enabled(c);
}});
}},_attachTreeHandlers:function(){var c=this.get_tree();
if(c!=null){c.add_nodeClicked(Function.createDelegate(this,this._onTreeNodeClicked));
c.add_nodeDoubleClick(Function.createDelegate(this,this._onTreeNodeDoubleClick));
c.add_contextMenuShowing(Function.createDelegate(this,this._onTreeContextMenuShowing));
c.add_contextMenuItemClicked(Function.createDelegate(this,this._onTreeContextMenuItemClicked));
c.add_nodeDropping(Function.createDelegate(this,this._onTreeNodeDropping));
c.add_nodeDragging(Function.createDelegate(this,this._checkCopyCursor));
c.add_mouseOver(Function.createDelegate(this,this._onTreeMouseOver));
c.add_mouseOut(Function.createDelegate(this,this._onTreeMouseOut));
c.add_nodeEdited(Function.createDelegate(this,this._onTreeNodeEdited));
c.add_keyPressing(Function.createDelegate(this,this._onTreeKeyPressing));
c.add_nodePopulated(Function.createDelegate(this,this._onTreeNodePopulated));
}},_isOverElement:function(d,c){while(d){if(d.id==c){return d;
}d=d.parentNode;
}return null;
},_onTreeNodePopulated:function(c,d){if(this._explorerMode==Telerik.Web.UI.FileExplorerMode.FileTree){var e=this._createItemFromTreeViewNode(d.get_node());
this.raiseEvent("folderLoaded",new Telerik.Web.UI.RadFileExplorerEventArgs(e,""));
}},_onTreeKeyPressing:function(c,d){var e=d.get_domEvent();
if(e&&e.keyCode==13){d.set_cancel(true);
$telerik.cancelRawEvent(e);
this._onTreeNodeDoubleClick(c,d);
}},_onTreeNodeEdited:function(c,e){var h=e.get_node();
if(h){var f=h.get_text();
var g=this._createItemFromTreeViewNode(h);
var d=new Telerik.Web.UI.RadFileExplorerEventArgs(g,f);
this.raiseEvent("move",d);
if(d.get_cancel()){return false;
}}},_onTreeMouseOver:function(c,d){this._currentTreeNode=d.get_node();
},_onTreeMouseOut:function(c,d){this._currentTreeNode=null;
},_onTreeNodeDropping:function(g,d){if(this._enableCopy){this._updateCopyCursor(false);
}var j=this._enableCopy&&d.get_domEvent().ctrlKey;
var e=j?"copy":"move";
var p=d.get_sourceNodes();
var u=d.get_destNode();
if(!u){var n=d.get_htmlElement();
if(!n){return;
}var v=this.get_grid();
var o=v!=null?this._isOverElement(n,v.get_id()):null;
if(o){d.set_htmlElement(o);
}else{d.set_cancel(true);
}}else{if(this._isNodeADirectory(u)){var c=u.get_value();
for(var m=0;
m<p.length;
m++){var r=this._createItemFromTreeViewNode(p[m]);
var f=new Telerik.Web.UI.RadFileExplorerEventArgs(r,c);
this.raiseEvent(e,f);
if(f.get_cancel()){d.set_cancel(true);
}}}else{d.set_cancel(true);
}}if(!d.get_cancel()){if(!j){for(var m=0;
m<p.length;
m++){var h=p[m].get_parent();
if(h&&h.get_value){var l=h.get_value();
var t=l+"***"+this._gridSortExpression;
this._folderCache[t]=null;
}}}var k=u;
if(d.get_htmlElement()){var s=this.get_currentDirectory();
var q=this.get_tree();
k=q.findNodeByValue(s);
}this.set_commandArgument(e);
}},_onTreeContextMenuShowing:function(c,d){var g=d.get_node();
var f=this._createItemFromTreeViewNode(g);
var e=this._setContextMenuItemsState(d.get_menu(),f.get_permissions());
if(!e){d.set_cancel(true);
$telerik.cancelRawEvent(d.get_domEvent());
}},_onTreeContextMenuItemClicked:function(j,f){var d=f.get_node();
var h=f.get_menuItem().get_value();
switch(h){case"Rename":d.startEdit();
break;
case"NewFolder":if(!this._isNodeADirectory(d)){d=d.get_parent();
}var i=d.get_value();
this.createNewDirectory(i);
break;
case"Delete":var c=this._createItemFromTreeViewNode(d);
this.deleteItem(c);
break;
case"Upload":this._showUploadWindow();
break;
case"Copy":var e=null;
if(!d.get_selected()){e=this._createItemFromTreeViewNode(d);
}this._copy("tree",e);
break;
case"Paste":var g=this._createItemFromTreeViewNode(d);
this._paste(g);
break;
}},_onTreeNodeDoubleClick:function(c,d){var f=d.get_node();
var e=this._createItemFromTreeViewNode(f);
this.open(e);
},_onTreeNodeClicked:function(c,e){var h=e.get_node();
var f=this._createItemFromTreeViewNode(h);
var g=c.get_multipleSelect()&&e.get_domEvent()&&(e.get_domEvent().ctrlKey||e.get_domEvent().shiftKey);
if(f.isDirectory()&&!g){var d=new Telerik.Web.UI.RadFileExplorerEventArgs(f,"");
this.raiseEvent("folderChange",d);
if(d.get_cancel()){return;
}h.expand();
this._makeGridCallback(f.get_path());
return true;
}return this.raise_itemSelected(f);
},_attachGridHandlers:function(){var c=this.get_grid();
if(c!=null){var d=this.get_gridContextMenu();
if(d!=null){d.add_itemClicked(Function.createDelegate(this,this._onGridMenuItemClicked));
}c.add_rowSelected(Function.createDelegate(this,this._onGridRowSelected));
c.add_rowDblClick(Function.createDelegate(this,this._onGridRowDblClick));
c.add_rowDataBound(Function.createDelegate(this,this._onGridRowDataBound));
c.add_rowContextMenu(Function.createDelegate(this,this._onGridRowContextMenu));
c.add_rowDragging(Function.createDelegate(this,this._checkCopyCursor));
c.add_rowDropping(Function.createDelegate(this,this._onGridRowDropping));
c.add_command(Function.createDelegate(this,this._onGridCommand));
this._gridContextHandler=Function.createDelegate(this,this._gridElementContextMenu);
$addHandler(this.get_gridPane().getContentElement(),"contextmenu",this._gridContextHandler);
c.add_keyPress(Function.createDelegate(this,this._onGridKeyPress));
}},_onGridRowDropping:function(g,l){if(this._enableCopy){this._updateCopyCursor(false);
}var m=this._currentTreeNode;
if(m){var j=this._enableCopy&&l.get_domEvent().ctrlKey;
var p={};
p.isCopying=j;
p.srcFolder=this.get_currentDirectory();
if(!this._isNodeADirectory(m)){m=m.get_parent();
}p.dstFolder=m.get_value();
if(p.srcFolder==p.dstFolder){l.set_cancel(true);
}else{p.items=[];
var f=l.get_draggedItems();
for(var c=0,n=f.length;
c<n;
c++){var k=f[c];
var o=k.get_dataItem();
var e=this._findItemByPath(this._getGridDataItemPath(o));
var h=e.isDirectory()?"D":"F";
var d=new Telerik.Web.UI.RadFileExplorerEventArgs(e,p.dstFolder);
this.raiseEvent(j?"copy":"move",d);
if(!d.get_cancel()){Array.add(p.items,h+e.get_path());
}}this._gridRowDroppedParams=p;
}}else{l.set_cancel(true);
}},_onGridKeyPress:function(c,f){var e=f.get_keyCode();
var d=c;
if(e==13){this.open();
return $telerik.cancelRawEvent(f.get_domEvent().rawEvent);
}},_onGridRowSelected:function(c,d){if(d&&d.get_domEvent&&d.get_domEvent().type=="mousedown"){return;
}var e=d.get_gridDataItem();
var h=e.get_dataItem();
if(h){var g=this._getGridDataItemPath(h);
var f=this._findItemByPath(g);
if(f!=null){return this.raise_itemSelected(f);
}}else{return false;
}},_getGridDataItemPath:function(d){if(!d){return null;
}var c=d.Path;
if(!c){c=this.get_currentDirectory();
if(c&&c.charAt(c.length-1)!=this.get_pathSeparator().charAt(0)){c+=this.get_pathSeparator();
}c+=d.Name;
}return c;
},_onGridRowDataBound:function(j,l){var s=l.get_dataItem();
var t=s.Name;
var m=s.Length;
var d="rfeFileExtension folder",c=null;
if(m==null){m="&nbsp;";
}else{c=t.substr(t.lastIndexOf(".")+1);
c=c.toLowerCase();
d="rfeFileExtension "+c;
}var q={type:(m=="&nbsp;"?Telerik.Web.UI.FileExplorerItemType.Directory:Telerik.Web.UI.FileExplorerItemType.File),permissions:s.Permissions,name:t,path:this._getGridDataItemPath(s),extension:c,size:m,url:s.Url};
Array.add(this._gridData,$create(Telerik.Web.UI.FileExplorerItem,q,null,null,null));
var p=l.get_item("Name").get_element();
var r=document.createElement("DIV");
r.className=d;
r.innerHTML=t.replace(/&/g,"&amp;");
r.setAttribute("unselectable","on");
var e=p.cells[0];
e.innerHTML="";
e.setAttribute("unselectable","on");
e.appendChild(r);
var h=p.cells[1];
h.setAttribute("unselectable","on");
h.innerHTML=m;
if(this._hasExtraColumns()){var f=j.get_masterTableView();
for(var k=2,u=p.cells.length;
k<u;
k++){var o=f.get_columns()[k].get_uniqueName();
var g=p.cells[k];
g.setAttribute("unselectable","on");
var n=s.Attributes[o];
g.innerHTML=n?n:"&nbsp;";
}}if(this._selectedFile){if(t==this._selectedFile){this._selectedFile=null;
this._selectedRow=l.get_item();
}}},_onGridCommand:function(f,j){j.set_cancel(true);
var g=j.get_commandName();
var e,h;
switch(g){case"Sort":e=f.get_masterTableView().get_sortExpressions();
h=e.toString();
var i=j.get_commandArgument();
this._makeGridCallback(this.get_currentDirectory(),true,h);
break;
case"RowDroppedHtml":var d=this._gridRowDroppedParams;
if(d){var c=d.isCopying?"CallbackFnCopy_":"GridDrag_";
c+=d.dstFolder+"***"+d.items.join("***");
var m=d.dstFolder+"***"+this._gridSortExpression;
this._folderCache[m]=null;
this._gridRowDroppedParams=null;
this._postbackTreeAjaxPanel(c);
}break;
case"Page":if(!this._bindingGridFlag){var l=f.get_masterTableView().get_currentPageIndex();
var k=f.get_masterTableView().get_pageSize();
e=f.get_masterTableView().get_sortExpressions();
if(e.length>0&&l>0){f.get_masterTableView().set_currentPageIndex(0);
}h=e.toString();
this._makeGridCallback(this.get_currentDirectory(),true,h,l*k,k);
}break;
}},_onGridRowDblClick:function(c,d){var g=d.get_gridDataItem().get_dataItem();
var e=this._getGridDataItemPath(g);
var f=this._findItemByPath(e);
this.open(f);
},_setContextMenuItemsState:function(f,h,i){if(f==null||f.get_items().get_count()==0){return false;
}var c=Telerik.Web.UI.FileExplorerItemPermissions;
var d=0;
var g=f.get_items();
var e=this._copiedPaths.length>0;
g.forEach(function(k){var j=true;
switch(k.get_value()){case"Upload":case"NewFolder":j=(h&c.Upload)!=0;
break;
case"Delete":j=(h&c.Delete)!=0;
j=j&&(i!=true);
break;
case"Rename":j=(h&(c.Upload|c.Delete))!=0;
j=j&&(i!=true);
break;
case"Copy":j=(i!=true);
break;
case"Paste":j=(h&c.Upload)!=0;
j=j&&e;
break;
}if(!j){d++;
}k.set_enabled(j);
});
return true;
},_gridElementContextMenu:function(c){var d=this.get_gridContextMenu();
var e=this._setContextMenuItemsState(d,this.get_currentPermissions(),true);
if(e){d.show(c);
}return $telerik.cancelRawEvent(c);
},_onGridRowContextMenu:function(k,j){var f=this.get_gridContextMenu();
var d=j.get_domEvent();
var i=j.get_itemIndexHierarchical();
var e=k.get_masterTableView();
var g=e.get_dataItems()[i];
this._gridContextMenuSelectedItem=g;
var c=g.get_element();
if(!g.get_selected()){e.clearSelectedItems();
this._selectGridItem(g);
}var h=this._setContextMenuItemsState(f,this.get_currentPermissions());
if(h){f.show(d);
}else{this._gridContextMenuSelectedItem=null;
}return $telerik.cancelRawEvent(d);
},_selectGridItem:function(f){var d=this.get_grid();
if(d==null){return;
}var c=f.get_element();
d.get_masterTableView().selectItem(c);
var e={};
e.get_gridDataItem=function(){return f;
};
this._onGridRowSelected(d,e);
},_onGridMenuItemClicked:function(f,k){var m=k.get_item().get_value();
var n,c;
var i=this._gridContextMenuSelectedItem;
if(i){n=i.get_dataItem();
c=this._getGridDataItemPath(n);
}switch(m){case"Rename":var o=n.Name;
var h=this.get_localization()["Rename"];
function e(p){if(p){this._renameGridItem(c,p);
}}var d=this;
var g=this.get_windowManager();
window.setTimeout(function(){g.radprompt(h,Function.createDelegate(d,e),330,100,null,h,o);
},10);
break;
case"Delete":this.deleteSelectedItems();
break;
case"Open":var j=this._findItemByPath(c);
this.open(j);
break;
case"NewFolder":this.createNewDirectory(this.get_currentDirectory());
break;
case"Upload":this._showUploadWindow();
break;
case"Copy":this._copy("grid");
break;
case"Paste":var l=this._findItemByPath(c);
if(l==null||!l.isDirectory()){gridItem=this._getCurrentFolderItem();
}this._paste(gridItem);
break;
}this._gridContextMenuSelectedItem=null;
},_renameGridItem:function(e,c){var d=new Telerik.Web.UI.RadFileExplorerEventArgs(this._findItemByPath(e),c);
this.raiseEvent("move",d);
if(d.get_cancel()){return false;
}this._postbackTreeAjaxPanel("CallbackFnRenameItem_"+e+"***"+c);
},_isNodeADirectory:function(d){if(this._explorerMode==Telerik.Web.UI.FileExplorerMode.Default){return true;
}else{var c=d.get_attributes();
return !c.getAttribute("Length");
}},_updateCopyCursor:function(c){if(c){Sys.UI.DomElement.addCssClass(this.get_element(),this._copyCursorClassName);
}else{Sys.UI.DomElement.removeCssClass(this.get_element(),this._copyCursorClassName);
}},_checkCopyCursor:function(c,d){if(this._enableCopy){var f=d.get_domEvent().ctrlKey;
var e=Sys.UI.DomElement.containsCssClass(this.get_element(),this._copyCursorClassName);
if(f!=e){this._updateCopyCursor(f);
}}},_hasExtraColumns:function(){if(this._gridHasExtraColumns==null){var c=this.get_grid().get_masterTableView();
this._gridHasExtraColumns=c.get_columns().length>2;
}return this._gridHasExtraColumns;
},_getCurrentFolderItem:function(){var c=this._createItemFromPath(this.get_currentDirectory());
return c;
},_createItemFromPath:function(d){var e=null;
var c=this.get_tree();
if(c!=null){var f=c.findNodeByValue(d);
e=this._createItemFromTreeViewNode(f);
}if(e==null&&this.get_grid()!=null){e=this._findItemByPath(d);
}return e;
},getFileExplorerItemFromNode:function(c){return this._createItemFromTreeViewNode(c);
},_createItemFromTreeViewNode:function(c){if(!c){return null;
}var e=c.get_attributes();
var i=e.getAttribute("Name");
var k=e.getAttribute("Length");
if(k){k=parseInt(k,10);
}var l=e.getAttribute("Path");
var f=parseInt(e.getAttribute("Permissions"),10);
var h=e.getAttribute("Url");
var m=k==null?Telerik.Web.UI.FileExplorerItemType.Directory:Telerik.Web.UI.FileExplorerItemType.File;
if(m==Telerik.Web.UI.FileExplorerItemType.File&&!l){var j=c.get_parent();
if(j){l=j.get_value();
if(l&&l.charAt(l.length-1)!=this.get_pathSeparator().charAt(0)){l+=this.get_pathSeparator();
}l+=i;
}}var g={type:m,permissions:f,name:i,path:l,size:k,url:h};
var d=$create(Telerik.Web.UI.FileExplorerItem,g,null,null,null);
return d;
},_hideLoadingPanel:function(d){if(d==null){return;
}var c=this.get_ajaxLoadingPanel();
if(c){c.hide(d);
}},_showLoadingPanel:function(d){if(d==null){return;
}var c=this.get_ajaxLoadingPanel();
if(c){c.show(d);
}},_findItemByPath:function(d){if(d){for(var e=0,c=this._gridData.length;
e<c;
e++){var f=this._gridData[e];
if(f.get_path()==d){return f;
}}}return null;
},get_selectedItems:function(){var h=[];
var n=this.get_grid();
var k=this.get_tree();
if(n!=null){var e=n.get_selectedItems();
if(e&&e.length>0){for(var c=0,m=e.length;
c<m;
c++){var o=e[c].get_dataItem();
var g=this._findItemByPath(this._getGridDataItemPath(o));
if(g){Array.add(h,g);
}}}}if(k!=null&&h.length==0){var l=k.get_selectedNodes();
for(var d=0;
d<l.length;
d++){var f=this._createItemFromTreeViewNode(l[d]);
Array.add(h,f);
}}return h;
},get_selectedItem:function(){return this.get_selectedItems()[0];
},_back:function(){var c=this._actionsManager.get_currentAction();
if(c==this.get_currentDirectory()){this._actionsManager.shiftPointerLeft();
}this._actionsManager.undo();
},_forward:function(){var c=this._actionsManager.get_nextAction();
if(c==this.get_currentDirectory()){this._actionsManager.shiftPointerRight();
}this._actionsManager.redo();
},_updateBackForward:function(c){this._actionsManager.addAction(c);
},_executeBackForward:function(c,d){var e=d.get_action();
this.loadFolder(e,false);
},get_currentDirectory:function(){return $get(this._currentDirectoryInputID).value;
},set_currentDirectory:function(c,d){if((null!=this._actionsManager)&&(c!=this.get_currentDirectory())&&(false!=d)){this._updateBackForward(c);
}$get(this._currentDirectoryInputID).value=c;
var f=this.get_tree();
node=f.findNodeByValue(c);
if(node){node.select();
}var e=$get(this.get_addressBox());
if(e){e.value=c;
}this._updateToolbar();
},get_currentPermissions:function(){var c=this._createItemFromPath(this.get_currentDirectory());
return c?c.get_permissions():null;
},raise_itemSelected:function(d){var c=new Telerik.Web.UI.RadFileExplorerEventArgs(d,"");
this.raiseEvent("itemSelected",c);
return !c.get_cancel();
},get_localization:function(){return this._localization;
},get_pathSeparator:function(){return this._pathSeparator;
},set_commandArgument:function(c){var d=$get(this._commandArgumentInputID);
if(d){d.value=c;
}},get_commandArgument:function(){var c=$get(this._commandArgumentInputID);
if(c){return c.value;
}else{return null;
}}};
b.registerControlProperties(a.RadFileExplorer,{allowPaging:false,enableOpenFile:true,addressBox:"",postbackButton:null,windowManager:null,gridPane:null,treePane:null,ajaxLoadingPanel:null,gridContextMenu:null,tree:null,grid:null,toolbar:null});
b.registerControlEvents(a.RadFileExplorer,["itemSelected","folderLoaded","fileOpen","folderChange","init","load","createNewFolder","delete","move","copy","ajaxRequestStart","ajaxRequestEnd"]);
Telerik.Web.UI.RadFileExplorer.registerClass("Telerik.Web.UI.RadFileExplorer",Telerik.Web.UI.RadWebControl);
Telerik.Web.UI.RadFileExplorerEventArgs=function(d,c){Telerik.Web.UI.RadFileExplorerEventArgs.initializeBase(this);
this._item=d;
this._newPath=c;
};
Telerik.Web.UI.RadFileExplorerEventArgs.prototype={get_path:function(){return this._item.get_path();
},get_newPath:function(){return this._newPath;
},get_item:function(){return this._item;
}};
Telerik.Web.UI.RadFileExplorerEventArgs.registerClass("Telerik.Web.UI.RadFileExplorerEventArgs",Sys.CancelEventArgs);
b.registerEnum(a,"FileExplorerItemType",{File:0,Directory:1});
b.registerEnum(a,"FileExplorerItemPermissions",{Read:1,Upload:2,Delete:4});
b.registerEnum(a,"FileExplorerMode",{Default:1,FileTree:2});
Telerik.Web.UI.FileExplorerItem=function(){Telerik.Web.UI.FileExplorerItem.initializeBase(this);
this._url="";
};
Telerik.Web.UI.FileExplorerItem.prototype={get_url:function(){return this._url?this._url:this._path;
},set_url:function(c){this._url=c;
},isDirectory:function(){return this._type==Telerik.Web.UI.FileExplorerItemType.Directory;
}};
b.registerControlProperties(a.FileExplorerItem,{size:"",extension:"",path:"",name:"",permissions:Telerik.Web.UI.FileExplorerItemPermissions.Read,type:Telerik.Web.UI.FileExplorerItemType.File});
Telerik.Web.UI.FileExplorerItem.registerClass("Telerik.Web.UI.FileExplorerItem",Sys.Component);
})();
